﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace 深入浅出WPF_Chapter7依赖属性
{
    /// <summary>
    /// Sample1.xaml 的交互逻辑
    /// </summary>
    public partial class Sample1 : Window
    {
        public Sample1()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Student stut = new Student();
            stut.SetValue(Student.NameProperty,this.textBox1.Text);
            textBox2.Text=(string)stut.GetValue(Student.NameProperty);
        }
    }

    public class Student : DependencyObject
    {
        public static readonly DependencyProperty NameProperty=DependencyProperty.Register("Name",typeof(string),typeof(Student));
        
        //CLR属性包装器
        public string Name
        {
            get { return (string)GetValue(NameProperty); }
            set { SetValue(NameProperty, value); }
        }
    }
}
